﻿function AzureOnlineQueuesView(context) {

    var self = this;

    var screen = ko.observable('');
    
    var queuesListView = new AzureOnlineQueuesListView(context, context.api);
    var queueMessagesListView = new AzureOnlineQueueMessagesListView(context);
    var deleteDetails = new AzureOnlineQueueDeleteView(context);
    var queueDetails = new AzureOnlineQueueDetailsView(context);

    var spaRuntime = context.spaRuntime;

    var queuesRoute = spaRuntime.findRouteByName('queues').addExecute(function (ev, args, phash) {
        screen('queues');
    });

    var messagesRoute = spaRuntime.findRouteByName('queueMessages').addExecute(function (ev, args, phash) {
        screen('messages');
    });
    
    context.api.subscribe(function () {
        if (spaRuntime.getCurrentRoute() == messagesRoute) {
            queuesRoute.navigateHash({});
        }
    });
    
    self.queuesListView = queuesListView;
    self.queueMessagesListView = queueMessagesListView;
    self.deleteDetails = deleteDetails;
    self.queueDetails = queueDetails;
    self.screen = screen;
    self.context = context;
}
